<?php
/**
 * Created by Zhy
 * User: Zhy
 * Date: 2020/4/20
 * Time: 17:54
 */

namespace app\admin\controller;


use think\Db;
use think\Request;

class About extends Base
{
    /**
     * 客服电话
     * @return mixed|\think\response\Json
     */
    public function servicePhone(){
        if(Request::instance()->isPost()){
            $service_phone = trim(input('phone'), ' ');
            $res = Db::table('up_other')->where('other_id', 4)->setField('other_phone', $service_phone);
            if($res){
                return json(['code' => 200, 'msg' => '保存成功']);
            }else{
                return json(['code' => 100, 'msg' => '保存失败']);
            }
        }
        $phone = Db::table('up_other')->where('other_id', 4)->value('other_phone');
        return $this->fetch('about/servicephone', ['phone' => $phone]);
    }
    
    /**
     * 邮箱
     * @return mixed|\think\response\Json
     */
    public function serviceEmail(){
        if(Request::instance()->isPost()){
            $service_email = trim(input('email'), ' ');
            $res = Db::table('up_other')->where('other_id', 4)->setField('other_email', $service_email);
            if($res){
                return json(['code' => 200, 'msg' => '保存成功']);
            }else{
                return json(['code' => 100, 'msg' => '保存失败']);
            }
        }
        $email = Db::table('up_other')->where('other_id', 4)->value('other_email');
        return $this->fetch('about/serviceemail', ['email' => $email]);
    }
    
    /**
     * 网址
     * @return mixed|\think\response\Json
     */
    public function serviceLink(){
        if(Request::instance()->isPost()){
            $service_link = trim(input('link'), ' ');
            $res = Db::table('up_other')->where('other_id', 4)->setField('other_link', $service_link);
            if($res){
                return json(['code' => 200, 'msg' => '保存成功']);
            }else{
                return json(['code' => 100, 'msg' => '保存失败']);
            }
        }
        $link = Db::table('up_other')->where('other_id', 4)->value('other_link');
        return $this->fetch('about/servicelink', ['link' => $link]);
    }
    
    /**
     * app描述
     * @return mixed|\think\response\Json
     */
    public function appDesc(){
        if(Request::instance()->isPost()){
            $app_desc = trim(input('desc'), ' ');
            $res = Db::table('up_other')->where('other_id', 4)->setField('other_app_desc', $app_desc);
            if($res){
                return json(['code' => 200, 'msg' => '保存成功']);
            }else{
                return json(['code' => 100, 'msg' => '保存失败']);
            }
        }
        $desc = Db::table('up_other')->where('other_id', 4)->value('other_app_desc');
        return $this->fetch('about/appdesc', ['desc' => $desc]);
    }
    
    /**
     * app一句话介绍
     * @return mixed|\think\response\Json
     */
    public function oneWord(){
        if(Request::instance()->isPost()){
            $oneword = trim(input('oneword'), ' ');
            $res = Db::table('up_other')->where('other_id', 4)->setField('other_one_word', $oneword);
            if($res){
                return json(['code' => 200, 'msg' => '保存成功']);
            }else{
                return json(['code' => 100, 'msg' => '保存失败']);
            }
        }
        $word = Db::table('up_other')->where('other_id', 4)->value('other_one_word');
        return $this->fetch('about/oneword', ['word' => $word]);
    }
    
    /**
     * appLogo
     * @return mixed|\think\response\Json
     */
    public function appLogo(){
        if(Request::instance()->isPost()){
            $logo = input('logo');
            $res = Db::table('up_other')->where('other_id', 4)->setField('other_logo', $logo);
            if($res){
                return json(['code' => 200, 'msg' => '保存成功']);
            }else{
                return json(['code' => 100, 'msg' => '保存失败']);
            }
        }
        $app_logo = Db::table('up_other')->where('other_id', 4)->value('other_logo');
        return $this->fetch('about/applogo', ['logo' => $app_logo]);
    }
    
    /**
     * app分享图片
     * @return mixed|\think\response\Json
     */
    public function appShare(){
        if(Request::instance()->isPost()){
            $share = input('share');
            $res = Db::table('up_other')->where('other_id', 4)->setField('other_app_share', $share);
            if($res){
                return json(['code' => 200, 'msg' => '保存成功']);
            }else{
                return json(['code' => 100, 'msg' => '保存失败']);
            }
        }
        $app_share = Db::table('up_other')->where('other_id', 4)->value('other_app_share');
        return $this->fetch('about/appshare', ['share' => $app_share]);
    }
}